//
//  RecommendProductResponse.m
//  EasyToo
//
//  Created by zhengzhe on 13-11-17.
//
//

#import "RecommendProductResponse.h"
#import "Goods.h"
#import "Merchant.h"

@implementation RecommendProductResponse

- (void)parse
{
    [super parse];
    
    if (self.bodyDict)
    {
        self.goodsArray = [[NSMutableArray alloc] init];
        
        NSArray *JsonArray = GetDictionaryArrayDefaultNil(self.bodyDict, @"good");
        for (int i = 0; i < [JsonArray count]; i++)
        {
            NSDictionary *jsonDict = [JsonArray objectAtIndex:i];
            Goods *goods = [[Goods alloc] initWithDictionary:jsonDict];
            [self.goodsArray addObject:goods];
            
            [goods release];
        }
        
        self.merchantArray = [[NSMutableArray alloc] init];
        
        JsonArray = GetDictionaryArrayDefaultNil(self.bodyDict, @"merchants");
        for (int i = 0; i < [JsonArray count]; i++)
        {
            NSDictionary *jsonDict = [JsonArray objectAtIndex:i];
            Merchant *merchant = [[Merchant alloc] initWithDictionary:jsonDict];
            [self.merchantArray addObject:merchant];
            
            [merchant release];
        }
    }
}

- (void)dealloc
{
    self.goodsArray = nil;
    self.merchantArray = nil;
    [super dealloc];
}

@end
